import React from 'react'
import Tit from '../../components/Tit'
import OrderShop from '../../components/OrderShop'
import { withRouter } from 'react-router-dom'
import './Refund.less'
class Refund extends React.Component {
    state = {
        OrderDetail: '',
        status: {
            '0': '正常',
            '1': '申请退货',
            '2': '同意退货',
            '3': '运输中',
            '4': '退货成功',
            '-1': '拒绝退货'
        }
    }
    GO (staus,id){
        console.log(staus,id)
        if(staus===2){
            this.props.history.push(`/ReturnOrder/${id}`)
        }
        this.props.history.push(`/RefundDetail/${id}`)
        
    }
    componentDidMount() {
        this.$postData('/api/order/getGoodsList', {}, params => {
            console.log(params)
            switch (params.code) {
                case 100:
                    this.setState({
                        OrderDetail: params.data
                    })
                    break;
                default:
                    this.Toast.info(params.msg);
                    break;
            }
        })
    }
    render() {
        return (
            <div>{this.state.OrderDetail ? <div>
                <Tit zz={true} tit={'退款售后'}></Tit>
                {this.state.OrderDetail.map((val, index) => (
                    <div key={index}>
                        <OrderShop data={val} status={val.status}></OrderShop>
                        <div className='Refund-d1 center'>
                            <p>{this.state.status[val.status]}</p>
                            <p onClick={this.GO.bind(this,val.status,val.id)} className={val.status === 2?'red center':'center'}>{val.status === 2 ? '填写物流信息' : '查看详情'}</p>
                        </div>
                        <div className='Refund-d2'></div>
                    </div>
                ))}
            </div> : <div></div>}</div>
        )
    }
}

export default withRouter(Refund)